package com.zmytest.model;

import com.zmytest.dto.UserDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.util.ObjectUtils;

import javax.persistence.Entity;
import java.time.LocalDate;

/**
 * Created on 2018/12/19.
 * 用户
 * @author zhangmingyu
 */
@Entity
@EqualsAndHashCode(callSuper = false)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User extends BaseModel<Long>{
    private String name;
    private LocalDate birth;
    private String mail;

    public void update(UserDto userDto){
        this.name = ObjectUtils.isEmpty(userDto.getName())? this.name:userDto.getName();
        this.birth = ObjectUtils.isEmpty(userDto.getBirth())? this.birth:userDto.getBirth();
        this.mail = ObjectUtils.isEmpty(userDto.getMail())? this.mail:userDto.getMail();
    }
}
